<template>
	<view class="login-content">
		<u-form-item label="账号"><u-input v-model="user" type="text" /></u-form-item>
		<u-form-item label="密码"><u-input v-model="password" type="password" /></u-form-item>
		<button type="default" @click="login">登录</button>
	</view>
</template>

<script>
	import {getPost} from "../../api/index.js"
	export default {
		data() {
			return {
				user:"",
				password:""
			};
		},
		methods:{
			login(){
				// console.log(this.user)
				// console.log(this.password)
				getPost("/pcUser/login",{username:this.user,password:this.password,rememberMe:true}).then(res=>{
					console.log(res)
					if(res.data.code==0){
						// #ifdef MP ||APP-PLUS
						console.log(res.cookies)
						uni.setStorageSync('cookie', res.cookies.join(";"))
						// #endif
						this.$store.commit("modifyLogin",{userInfo:res.data.userInfo,isLogin:true})
						uni.reLaunch({
								url:`../mine/mine?login=true`
						})
					}
				})
			}
		}
	}
</script>

<style lang="less">
.login-content{
	padding: 50rpx;
}
</style>
